home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / man / cat3 / DetachPids.3 < prev    next >
Text File  |  1994-09-20  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4. Tcl_DetachPids(3)    Tcl Library Procedures
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NAME
  11.      Tcl_DetachPids,   Tcl_ReapDetachedProcs   -   manage   child
  12.      processes in background
  13.  
  14. SYNOPSIS
  15.      #include <tcl.h>
  16.  
  17.      Tcl_DetachPids(_n_u_m_P_i_d_s, _p_i_d_P_t_r)
  18.  
  19.      Tcl_ReapDetachedProcs()                                       |
  20.  
  21. ARGUMENTS
  22.      int   _n_u_m_P_i_d_s      (in)      Number of process ids contained
  23.                                   in  the  array  pointed  to  by
  24.                                   _p_i_d_P_t_r.
  25.  
  26.      int   *_p_i_d_P_t_r      (in)      Address  of  array   containing
  27.                                   _n_u_m_P_i_d_s process ids.
  28. _________________________________________________________________
  29.  
  30.  
  31. DESCRIPTION
  32.      Tcl_DetachPids and Tcl_ReapDetachedProcs provide a mechanism  |
  33.      for  managing  subprocesses  that are running in background.  |
  34.      These procedures are needed because the parent of a  process  |
  35.      must  eventually invoke the waitpid kernel call (or one of a  |
  36.      few other similar kernel calls) to wait  for  the  child  to  |
  37.      exit.   Until  the  parent  waits for the child, the child's  |
  38.      state cannot be completely reclaimed by the  system.   If  a  |
  39.      parent  continually  creates  children  and  doesn't wait on  |
  40.      them, the system's process table will  eventually  overflow,  |
  41.      even if all the children have exited.                         |
  42.  
  43.      Tcl_DetachPids may be called to ask Tcl to take responsibil-  |
  44.      ity  for  one  or  more processes whose process ids are con-  |
  45.      tained in the _p_i_d_P_t_r array passed as argument.   The  caller  |
  46.      presumably has started these processes running in background  |
  47.      and doesn't want to have to deal with them again.             |
  48.  
  49.      Tcl_ReapDetachedProcs invokes the  waitpid  kernel  call  on  |
  50.      each  of  the  background processes so that its state can be  |
  51.      cleaned up if it has exited.  If the process  hasn't  exited  |
  52.      yet,  Tcl_ReapDetachedProcs doesn't wait for it to exit;  it  |
  53.      will check again the next time it is invoked.  Tcl automati-  |
  54.      cally calls Tcl_ReapDetachedProcs each time the exec command  |
  55.      is executed, so in most cases it  isn't  necessary  for  any  |
  56.      code  outside  of Tcl to invoke Tcl_ReapDetachedProcs.  How-  |
  57.      ever, if you call Tcl_DetachPids  in  situations  where  the  |
  58.      exec  command  may  never get executed, you may wish to call  |
  59.      Tcl_ReapDetachedProcs from time to time so  that  background  |
  60.  
  61.  
  62.  
  63. Tcl                                                             1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Tcl_DetachPids(3)    Tcl Library Procedures
  71.  
  72.  
  73.  
  74.      processes can be cleaned up.
  75.  
  76.  
  77. KEYWORDS
  78.      background, child, detach, process, wait
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Tcl                                                             2
  130.  
  131.  
  132.  
  133.